<?php

print_r($_POST);
 
// username and password sent from form 

//[user1] => 1 [source] => 11 [inv_id] => 23 [val] => [amount] => 77 [number] => 1 


if(!isset($_POST['user1'])||!isset($_POST['number'])||!isset($_POST['inv_id'])){
	$source=$_POST['source'];
	header("location:../index.php?page=organization_consume&id=".$source."&stat=error&error=missing");
	return;
}
	$source=$_POST['source'];
	$number=$_POST['number'];
	$inv_id=$_POST['inv_id'];
	$user1=$_POST['user1']; 
	$scan_code=inventory_scan_code($inv_id);
	$limit= inventory_limit($inv_id);
	if($limit<$number){
		header("location:../index.php?page=organization_consume&id=".$source."&stat=error&error=badData");
		return;
	}
consumeItem($inv_id,$scan_code,$limit,$number,$source,0,$user1,"");
return;
	if(consumeItem($inv_id,$scan_code,$limit,$number,$source,0,$user1,"")){
		header("location:../index.php?page=organization_consume&id=".$source."&stat=consumed");
	}else{
		header("location:../index.php?page=organization_consume&id=".$source."&stat=error&error=badData");
	}
	
		return;
?>